package cn.itsource.controller.app;


import cn.dev33.satoken.annotation.SaIgnore;
import cn.itsource.pojo.app.dto.AppRegisterDto;
import cn.itsource.pojo.app.vo.GeoVo;
import cn.itsource.pojo.app.vo.SummaryVo;
import cn.itsource.pojo.domain.DriverAuthMaterial;
import cn.itsource.result.R;
import cn.itsource.service.IDriverAuthMaterialService;
import cn.itsource.service.IDriverService;
import cn.itsource.service.IDriverSettingService;
import cn.itsource.service.IDriverSummaryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Tag(name = "App端司机API",description = "App端司机API")
@RestController
@RequestMapping("/app/driver")
public class AppDriverController {

    @Autowired
    private IDriverService driverService;

    @Autowired
    private IDriverAuthMaterialService driverAuthMaterialService;

    @Autowired
    private IDriverSummaryService   driverSummaryService;

    @Autowired
    private IDriverSettingService driverSettingService;


    @Operation( summary= "实时更新司机位置",description = "实时更新司机位置")
    @Parameter(name = "geo",description = "实时更新司机位置",required = true)
    @PostMapping("/geo")
    public R geo(@RequestBody @Valid GeoVo  vo) {
        driverService.geo(vo);
        return R.success();
    }
    @Operation( summary= "停止接单",description = "停止接单")
    @Parameter(name = "stopworkhandle",description = "停止接单",required = true)
    @PostMapping("/stopworkhandle")
    public R stopWorkHandle(){
        driverSettingService.stopWorkHandle();
        return R.success();
    }

    @Operation( summary= "开始接单",description = "开始接单")
    @Parameter(name = "startworkhandle",description = "开始接单",required = true)
    @PostMapping("/startworkhandle")
    public R startWorkHandle(){
        driverSettingService.startWorkHandle();
        return R.success();
    }


    @Operation( summary= "工作台渲染",description = "工作台渲染")
    @Parameter(name = "workbenchdata",description = "工作台渲染",required = true)
    @GetMapping("/workbenchdata")
    public R workBenchData(){
        SummaryVo summaryVo = driverSummaryService.workBenchData();
        return R.success(summaryVo);
    }

    @Operation( summary= "司机注册",description = "司机注册")
    @Parameter(name = "driver",description = "保存的对象",required = true)
    @PostMapping("/register")
    public R register(@RequestBody @Valid AppRegisterDto appRegisterDto){
        driverService.register(appRegisterDto);
        return R.success();
    }



    @Operation( summary= "认证信息",description = "认证信息")
    @Parameter(name = "material",description = "认证信息",required = true)
    @PostMapping("/material")
    public R material(@RequestBody @Valid DriverAuthMaterial material)  {
        driverAuthMaterialService.material(material);
        return R.success();
    }

    @Operation( summary= "回显认证信息",description = "回显认证信息")
    @Parameter(name = "echoMaterial",description = "回显认证信息",required = true)
    @PostMapping("/echo")
    public R echoMaterial(){
        DriverAuthMaterial material = driverAuthMaterialService.echoMaterial();
        return R.success(material);
    }

    @Operation( summary= "人脸识别",description = "人脸识别")
    @Parameter(name = "face",description = "人脸识别",required = true)
    @PostMapping("/face")
    @SaIgnore
    public R face(){
        driverAuthMaterialService.face();
        return R.success();
    }


}
